﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using X.Web;

namespace X.WebSite.Admin.Product
{
    public partial class List : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }

        private void BindGrid()
        {
            gvProductList.DataSource = Bll.Product.GetList();
            gvProductList.DataBind();
        }

        protected void gvProductList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int productId = Convert.ToInt32(gvProductList.DataKeys[e.RowIndex].Value);

            Bll.Product.Delete(productId);

            BindGrid();
        }
    }
}